        var fundPayStore = new Ext.data.JsonStore({
			url: '/weihe/getPayList_fundManager',
			root: 'datas',
			fields : [{
						name:'FundPayId',mapping:'id'
					},{
						name:'FundPayType',mapping:'type'
					},{
						name:'FundPayCompany',mapping:'company'
					},{
						name:'FundPayContent',mapping:'content'
					},{
						name:'FundPayHandler',mapping:'handler'
					},{
				    	name:'FundPayRcash',mapping:'rcash'
				    },{
				    	name:'FundPayRbank',mapping:'rbank'
				    },{
				    	name:'FundPayDcash',mapping:'dcash'
				    },{
				    	name:'FundPayDbank',mapping:'dbank'
				    },{
     				   name:'FundPayDate', mapping:'date',type : 'date', dateFormat:"Y-m-d"
      			  	}],
				    baseParams : {'fundPay.type': 'local'},
					listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_fundManager',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    	
    	

fundPays = function(){
	
  return{
	  
	  shallPayGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 5,
			store : shallPayStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		});

	

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		 
	   var shallPayGrid = new Ext.grid.GridPanel({
		   id:'sPGrid',
		   title : '货币资金',
		   region : 'north',
		   height : 230,
		   minColumnWidth : 50,
		   tbar:["-",{
	   						text:"输入查询条件",
								handler:function(){
										shallPays.infoWin().show();
								}
	   					},"-",{
	   						text:"查看全部",
								handler:function(){
									Ext.getCmp("sPGrid").getStore().baseParams = {'flag': false,'shallPay.type': 'local'};
									Ext.getCmp("sPGrid").getStore().load({params : {start : 0, limit : 5}});
								}
	   			},"-"],
		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : shallPayStore,
		   columns: [
		             {header : '公司名称', dataIndex : 'ShallPayCompany',renderer:function(value){
							if(value != ""){
									return value;
								}else{
									return "合计";
								}
		             }},
		             {header : '支付内容', dataIndex : 'ShallPayContent'},
		             {header : '申请人', dataIndex : 'ShallPayProposer'},
		             {header : '付款期限', dataIndex : 'ShallPayDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
		             {header : '(人民币)现金', dataIndex : 'ShallPayRcash'},
		             {header : '(人民币)银行', dataIndex : 'ShallPayRbank'},
		             {header : '(美金)现金', dataIndex : 'ShallPayDcash'},
		             {header : '(美金)银行', dataIndex : 'ShallPayDbank'}
      ],
         sm : rowSelectionModel,
         listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			   		if(record.get('ShallPayContent')==""){
			   			Ext.Msg.alert('提示','不能编辑统计数据');
			   		}else{
				   	   Ext.getCmp("fundPayForm").form.findField('id').setValue(record.id);
					   Ext.getCmp("fundPayForm").form.findField('fundPay.company').setValue(record.get('ShallPayCompany'));
					   Ext.getCmp("fundPayForm").form.findField('fundPay.content').setValue(record.get('ShallPayContent'));
					   Ext.getCmp("fundPayForm").form.findField('fundPay.rcash').setValue(record.get('ShallPayRcash'));
					   Ext.getCmp("fundPayForm").form.findField('fundPay.rbank').setValue(record.get('ShallPayRbank'));
					   Ext.getCmp("fundPayForm").form.findField('fundPay.dcash').setValue(record.get('ShallPayDcash'));
					   Ext.getCmp("fundPayForm").form.findField('fundPay.dbank').setValue(record.get('ShallPayDbank'));
			   		}
			   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return shallPayGrid;
	},
  	
	  fundPayGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 5,
			store : fundPayStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		});

	

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		 
	   var fundPayGrid = new Ext.grid.GridPanel({
		   id:'fundPayGrid',
		   title : '当日付款',
		   region : 'center',
		   minColumnWidth : 50,
		   tbar:["-",{
	   						text:"输入查询条件",
								handler:function(){
										fundPays.infoWin().show();
								}
	   					},"-",{
	   						text:"查看当日",
								handler:function(){
									Ext.getCmp("fundPayGrid").getStore().baseParams = {'flag': false,'fundPay.type': 'local'};
									Ext.getCmp("fundPayGrid").getStore().load({params : {start : 0, limit : 5}});
								}
	   			},"-"],
		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : fundPayStore,
		   columns: [
		             {header : '名称', dataIndex : 'FundPayCompany',renderer:function(value){
							if(value != ""){
									return value;
								}else{
									return "合计";
								}
		             }},
		             {header : '款项内容', dataIndex : 'FundPayContent'},
		             {header : '经手人', dataIndex : 'FundPayHandler'},
		             {header : '付款日期', dataIndex : 'FundPayDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
		             {header : '(人民币)现金', dataIndex : 'FundPayRcash'},
		             {header : '(人民币)银行', dataIndex : 'FundPayRbank'},
		             {header : '(美金)现金', dataIndex : 'FundPayDcash'},
		             {header : '(美金)银行', dataIndex : 'FundPayDbank'}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			   if(record.get('FundPayContent')==""){
			   			Ext.Msg.alert('提示','不能编辑统计数据');
			   	}else{
				   Ext.getCmp("fundPayForm").form.loadRecord(record);
				   Ext.getCmp("fundPayForm").buttons[0].setText('修改');
			   	}
			   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return fundPayGrid;
	},
	
	infoWin : function(){
	  	  var infoWin = new Ext.Window({
	  	  	id: 'fundPayInfo',
	        title:'当日付款查询',
	        layout: 'fit',
	        width:330,    
	        height:250,
	        modal: true,
	        draggable : false,
	        resizable: false,
	        closeAction:"close",
	        plain:true,    
	        items:[fundPays.queryForm()] 
	        
	    });  
	  		return infoWin;
	  	},
	  	
	  	queryForm : function(){
	  		
	  	 var queryForm = new Ext.form.FormPanel({
				baseCls:"x-plain",
				frame : true,
				autoHeight : true,
				labelAlign : 'right',
				labelWidth : 85,
				defaultType : 'textfield',
					defaults : {
					width : 200
				},
				items : [{
						  fieldLabel: "单位名称",
	      	    		  name: "fundPay.company"
				 	  },{
						  fieldLabel: "经手人",
	      	    		  name: "fundPay.handler"
				 	  },{
	            		  xtype: 'datefield',
	                      fieldLabel: "日期",
	                      format : 'Y-m-d',
	            		  name: "fundPay.date"
					   }],
				buttons:[{
	        		 text:'确认',
	             	 handler:function(){
	             	 	var company = queryForm.form.findField('fundPay.company').getValue()
	             	 	var handler = queryForm.form.findField('fundPay.handler').getValue()
	             	 	var date = queryForm.form.findField('fundPay.date').getValue();
					 Ext.getCmp("fundPayGrid").getStore().baseParams = {'flag': true,'fundPay.company':company,
						 													  'fundPay.handler':handler,
						 													  'fundPay.date':date,
						 													  'fundPay.type': 'local' };
					 Ext.getCmp("fundPayGrid").getStore().load({params : {start : 0, limit : 5}});
					 queryForm.form.reset();
	                 Ext.getCmp("fundPayInfo").close();
	              	
	              	}
	              },{
	                 text:'取消',
	                 handler:function(){
	                 	queryForm.form.reset();
	                 	Ext.getCmp("fundPayInfo").close();
	                 }
	              }]   
	        });
	        return queryForm;
	  	
	  	},
	
	
	
	fundPayForm : function(){
		var button_add = new Ext.Button({
			text : '添加',
			handler : function() {
					progressConsole();
				if(fundPayForm.form.isValid()){ 	
					if (fundPayForm.form.findField("fundPay.id").getValue() == "") {
						fundPayForm.form.submit({
						  url : '/weihe/addPay_fundManager',
						   success : function(form, action) {
							   if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
								  }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
									   handlerStore.reload();
									   if(fundPayForm.form.findField('id').getValue() != ""){
									   		Ext.getCmp("sPGrid").getStore().reload();
									   }
									   fundPayForm.form.reset();
									   Ext.getCmp("fundPayGrid").getStore().reload();
								});
							  }
						    }
					    });
					}else {
						fundPayForm.form.submit({
							  url : '/weihe/updatePay_fundManager',
							   success : function(form, action) {
								   if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
								  }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
										fundPayForm.form.reset();
										Ext.getCmp("fundPayGrid").getStore().reload();
										fundPayForm.buttons[0].setText('添加');
										
									});
								  }
							    }
						    });
					}
			}else{
				Ext.Msg.alert('提示','请输入相关内容');
			}
				}
		
			
		});

	var button_clear = new Ext.Button({
		id : 'button_clear',
		text : '清空',
		handler : function() {
			fundPayForm.form.reset();
			fundPayForm.buttons[0].setText('添加');
		}
	});

	var button_del = new Ext.Button({
		text : '删除',
		handler : function() {
			var id = fundPayForm.form.findField('fundPay.id').getValue();
			if (id == '') {
				Ext.Msg.alert('提示', '请选择需要删除的信息!');
			} else {
				progressConsole();
				Ext.Ajax.request({
					url : '/weihe/deletePay_fundManager',
					success : function(response) {
						var json = Ext.decode(response.responseText);
						if (json.success) {
							if (json.deny) {
								Ext.Msg.alert('消息', json.msg);
								fundPayForm.form.reset();
								fundPayForm.buttons[0].setText('添加');
							}else{
							Ext.Msg.alert('消息', json.msg, function() {
								Ext.getCmp("fundPayGrid").getStore().load({params : {start : 0, limit : 5}});
								fundPayForm.form.reset();
								fundPayForm.buttons[0].setText('添加');
							});
						  }
						}else{
							Ext.Msg.alert('消息', json.msg);
						}
					},
					failure : function() {
						Ext.Msg.alert('错误', '删除失败!');
					},
					params : 'fundPay.id=' + id
				});
			}
		}
	});
	
	var handlerStore = new Ext.data.JsonStore({
		url: '/weihe/getCombo_fundManager',
		root:'handler',
		fields:['value'],
		baseParams: {'type':'handler'}
	});

	
	var handlerCombo = {
			id:'FundPayHandler',
			xtype: 'combo',
			store: handlerStore,
			displayField: 'value',
			editable: true,
			mode: 'remote',
			triggerAction: 'all',
			fieldLabel : '经手人',
			emptyText: '可选择...',
			name : 'fundPay.handler'
			
	}
	
	 var chooseComboData = new Ext.data.SimpleStore({
			fields : ['text'],
			data : [['无'],['应付'],['应收']]
			});
	
	
	var chooseCombo = {
			id:'FundPayChoose',
			xtype: 'combo',
			store: chooseComboData,
			displayField: 'text',
			editable: true,
			triggerAction: 'all',
			fieldLabel : '跳转选项',
			mode : 'local',
			allowBlank:false,
			emptyText: '请选择...',
			name : 'choose'
			
	}

	var  fundPayForm = new Ext.form.FormPanel({
		id : 'fundPayForm',
		title : '货币资金信息',
		frame : true,
		width : 330,
		region : 'east',
		autoScroll : true,
		collapseMode :'mini',
		collapsible : true,
		labelAlign : 'right',
		labelWidth : 90,
		defaultType : 'textfield',
			defaults : {
			width : 200
		},
		items : [{  
			id:'FundPayId',
			xtype : 'hidden',  
			name : 'fundPay.id'
		},{  
			xtype : 'hidden',  
			name : 'id'
		},{  
			id:'FundPayType',
			xtype : 'hidden',
			name : 'fundPay.type',
			value: 'local'
		},{
			id:'FundPayCompany',
			fieldLabel : '名称',
			name : 'fundPay.company'
		},{
			id:'FundPayContent',
			fieldLabel : '款项内容',
			name : 'fundPay.content'
		},handlerCombo,{
			id: 'FundPayDate',
            xtype: 'datefield',
            fieldLabel: "付款日期",
            format : 'Y-m-d',
			allowBlank:false,
            name: "fundPay.date",
            value : (new Date()).format('Y-m-d')
		},{
			id:'FundPayRcash',
			fieldLabel : '(人民币)现金',
			name : 'fundPay.rcash',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FundPayRbank',
			fieldLabel : '(人民币)银行',
			name : 'fundPay.rbank',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FundPayDcash',
			fieldLabel : '(美金)现金',
			name : 'fundPay.dcash',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'FundPayDbank',
			fieldLabel : '(美金)银行',
			name : 'fundPay.dbank',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},chooseCombo],
		buttons : [button_add,button_clear,button_del]
	});
		return  fundPayForm;
	}
  }
}();








